package com.wsz.pojo;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * 
 * @TableName user
 */
@TableName(value ="user")
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties({"accountNonExpired", "accountNonLocked", "credentialsNonExpired", "authorities"})
public class User implements Serializable, UserDetails {

    /**
     * 用户id
     */
    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 逻辑删除
     */
    @TableLogic
    private Integer isDeleted;

    /**
     * 账户是否启用
     */
    private boolean enabled;

    /**
     * 账户是否过期
     */
    private boolean accountnonexpired;

    /**
     * 账户是否被锁
     */
    private boolean accountnonlocked;

    /**
     * 密码是否过期
     */
    private boolean credentialsnonexpired;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public void setAccountnonexpired(boolean accountnonexpired) {
        this.accountnonexpired = accountnonexpired;
    }

    public void setAccountnonlocked(boolean accountnonlocked) {
        this.accountnonlocked = accountnonlocked;
    }

    public void setCredentialsnonexpired(boolean credentialsnonexpired) {
        this.credentialsnonexpired = credentialsnonexpired;
    }

    @Override
    public boolean isAccountNonExpired() {
        return !accountnonexpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return !accountnonlocked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return !credentialsnonexpired;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }
}